package com.vodone.v1pin.video.view.widgts
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.geom.Point;
	import mx.core.UIComponent;
	[Style(name="lineColor", type="unit", format="Color", inherit="no")] // 虚线线条颜色
	[Style(name="lineAlpha", type="Number", format="Number", inherit="no")] // 虚线线条透明度
	[Style(name="pointDistance", type="Number", format="Number", inherit="no")] // 虚线线条中两个点间距
	
	
	public class DashLine extends UIComponent{
		public function DashLine(){
			this.height = 1;
			this.percentWidth = 100;
		}
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			var lineColor:uint = getStyle('lineColor');
			var lineAlpha:Number = getStyle('Alpha');
			var pointDistance:Number = getStyle('pointDistance');
			if(isNaN(lineColor)) {
				lineColor = 0x000000;
			}
			if(isNaN(lineAlpha)) {
				lineAlpha = 1;
			}
			if(isNaN(pointDistance)) {
				pointDistance = 2;
			}
			drawVirtualLine(this,lineColor,pointDistance,this.width);
		}
		/**  
		 *  画虚线  
		 *  @param u 指定画虚线的容器  
		 *  @param w 指定虚线的长度(间距)  
		 *  @param uw 指定所画虚线的总长度  
		 *  @author LHY 2011-11-11  
		 */  
		public static  function drawVirtualLine(u:UIComponent,lineColor:uint,w:Number,uw:Number):void  
		{  
			u.graphics.clear();//清除绘制到此 Graphics 对象的图形，并重置填充和线条样式设置。  
			u.graphics.lineStyle(1,lineColor,1);//指定一种线条样式  
			var wid:Number=0;  
			var i:int = 0;  
			while(wid<uw){  
				u.graphics.moveTo(0+2*w*i,0);  
				u.graphics.lineTo(0+w+2*w*i,0);  
				wid+=w*2;  
				i++;  
				}  
		}  
	}
}